#!/usr/bin/env node

const fs = require('fs'),
      src = process.argv[2],
      target = process.argv[3];

if(!fs.existsSync(src)){
  console.error(`${src} is not exist!`);
  process.exit(1);
}

//复制文件内容
let target_content = fs.createReadStream(src).pipe(fs.createWriteStream(target));

//复制文件权限
target_content.on('close',() => {
  fs.chmodSync(target,fs.statSync(src).mode);
});
